/*
Copyright © 2024 wjsmc
*/
package main

import (
	"log"
	"os"

	"nodemessage.com/ruov-cli/cmd"
	"nodemessage.com/ruov-cli/consts"
	"nodemessage.com/ruov-cli/rlog"
	"nodemessage.com/ruov-cli/utils"
	"nodemessage.com/ruov-cli/utils/logger"
)

func init() {
	appLogger, err := logger.NewLogger(logger.Config{
		Level:      logger.DEBUG,
		LogPath:    consts.LogPath,
		FilePrefix: "ruov-cli",
		FileOutput: true,
	})
	if err != nil {
		log.Println("日志初始化失败:", err)
		os.Exit(1)
	}
	rlog.Logger = appLogger
}

func main() {
	// 尝试更新内部统计信息，但不阻止程序运行
	if _, err := os.Stat(consts.SettingFile); err == nil {
		// 仅当配置文件存在时更新
		err := utils.UpdateInternalStats()
		if err != nil {
			rlog.Logger.Debug("更新内部统计信息失败: %v", err)
		}
	}

	cmd.Execute()
}
